/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ejb;

import entities.Responsable;
import java.util.List;
import javax.ejb.Stateless;
import javax.ejb.LocalBean;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author curso
 */
@Stateless
@LocalBean
public class ServicioResponsable {

   
  @PersistenceContext(unitName="BSCPU")
    private EntityManager em;
    
    public void altaResponsable(Responsable p){
        em.persist(p);    
    }
    public Responsable buscaPorId(int id){
        return em.find(Responsable.class, id);
    }
    public List<Responsable> verResponsables(){
        return em.createNamedQuery("Responsable.findAll").getResultList();
    }
    public void borraResponsable(int id){
        Responsable a=em.find(Responsable.class, id);
        em.remove(a);    
    }
}
